﻿using MediatR;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Infrastructure.Interfaces;
using Traceability_Management.Read.Api.Application.Command.Processiings_CompanyWay;
using Traceability_Management.Read.Api.Application.Command.Processiings_FourWay;

namespace Traceability_Management.Read.Api.Application.CommandHandler.Processiings_CompanyWay
{
    public class UpdateProcessiings_CompanyWayCommandHandler : IRequestHandler<UpdateProcessiings_CompanyWayCommand, ApiResult<int>>
    {
        IBaseReponsitory<Processiings_Company> Processiings_Company;

        public UpdateProcessiings_CompanyWayCommandHandler(IBaseReponsitory<Processiings_Company> Processiings_Company)
        {
            this.Processiings_Company = Processiings_Company;
        }

        public async Task<ApiResult<int>> Handle(UpdateProcessiings_CompanyWayCommand request, CancellationToken cancellationToken)
        {
            await Processiings_Company.UpdateAsync(request.Processiings_Company);
            return new ApiResult<int>
            {
                Code = ApiEnum.Success,
                Message = "添加成功",
                Data = 1
            };
        }
    }
}
